package org.creativor.rayson.transport.server;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.nio.channels.ServerSocketChannel;
import org.creativor.rayson.api.TransferService;
import org.creativor.rayson.demo.server.DemoTransferService;
import org.creativor.rayson.transport.server.transfer.TransferConnector;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
 * The class <code>TransportServerTest</code> contains tests for the class
 * <code>{@link TransportServer}</code>.
 * <p>
 * Copyright Creativor Studio (c) 2011
 * 
 * @generatedBy CodePro at 11-5-7 上午3:16
 * @author Nick Zhang
 * @version $Revision: 1.0 $
 */
public class TransportServerTest {
	/**
	 * Launch the test.
	 * 
	 * @param args
	 *            the command line arguments
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:16
	 */
	public static void main(String[] args) {
		new org.junit.runner.JUnitCore().run(TransportServerTest.class);
	}

	/**
	 * Perform pre-test initialization.
	 * 
	 * @throws Exception
	 *             if the initialization fails for some reason
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:16
	 */
	@Before
	public void setUp() throws Exception {
		// TODO: add additional set up code here
	}

	/**
	 * Perform post-test clean-up.
	 * 
	 * @throws Exception
	 *             if the clean-up fails for some reason
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:16
	 */
	@After
	public void tearDown() throws Exception {
		// TODO: add additional tear down code here
	}

	/**
	 * Run the ServerConfig getConfig() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:16
	 */
	@Test
	public void testGetConfig_1() throws Exception {
		TransportServer fixture = new TransportServer(1);

		ServerConfig result = fixture.getConfig();

		// TODO: add additional test code here
		assertNotNull(result);
		assertEquals(false, result.debug());
		assertEquals(6660, result.portNumber());
		assertEquals(4, result.workerCount());
		assertEquals(
				"@org.creativor.rayson.transport.server.ServerConfig(portNumber=6660, debug=false, workerCount=4)",
				result.toString());
	}

	/**
	 * Run the ConnectionManager getConnectionManager() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:16
	 */
	@Test
	public void testGetConnectionManager_1() throws Exception {
		TransportServer fixture = new TransportServer(1);

		ConnectionManager result = fixture.getConnectionManager();

		// TODO: add additional test code here
		assertNotNull(result);
		assertEquals(0, result.size());
		assertEquals("Thread[Connection manager,1,main]", result.toString());
		assertEquals(false, result.isInterrupted());
		assertEquals("Connection manager", result.getName());
		assertEquals(0, result.countStackFrames());
		assertEquals(6990L, result.getId());
		assertEquals(1, result.getPriority());
		assertEquals(false, result.isAlive());
		assertEquals(true, result.isDaemon());
	}

	/**
	 * Run the PacketManager getPacketManager() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:16
	 */
	@Test
	public void testGetPacketManager_1() throws Exception {
		TransportServer fixture = new TransportServer(1);

		PacketManager result = fixture.getPacketManager();

		// TODO: add additional test code here
		assertNotNull(result);
	}

	/**
	 * Run the int getPortNumber() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:16
	 */
	@Test
	public void testGetPortNumber_1() throws Exception {
		TransportServer fixture = new TransportServer(1);

		int result = fixture.getPortNumber();

		// TODO: add additional test code here
		assertEquals(1, result);
	}

	/**
	 * Run the RpcConnector getRpcConnector() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:16
	 */
	@Test
	public void testGetRpcConnector_1() throws Exception {
		TransportServer fixture = new TransportServer(1);

		RpcConnector result = fixture.getRpcConnector();

		// TODO: add additional test code here
		assertNotNull(result);
	}

	/**
	 * Run the ServerSocketChannel getSocketChannel() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:16
	 */
	@Test
	public void testGetSocketChannel_1() throws Exception {
		TransportServer fixture = new TransportServer(1);

		ServerSocketChannel result = fixture.getSocketChannel();

		// TODO: add additional test code here
		assertEquals(null, result);
	}

	/**
	 * Run the TransferConnector getTransferConnector() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:16
	 */
	@Test
	public void testGetTransferConnector_1() throws Exception {
		TransportServer fixture = new TransportServer(1);

		TransferConnector result = fixture.getTransferConnector();

		// TODO: add additional test code here
		assertNotNull(result);
	}

	/**
	 * Run the int getVersion() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:16
	 */
	@Test
	public void testGetVersion_1() throws Exception {
		TransportServer fixture = new TransportServer(1);

		int result = fixture.getVersion();

		// TODO: add additional test code here
		assertEquals(1, result);
	}

	/**
	 * Run the void registerService(TransferService) method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:16
	 */
	@Test
	public void testRegisterService_1() throws Exception {
		TransportServer fixture = new TransportServer(1);
		TransferService service = new DemoTransferService();

		fixture.registerService(service);

		// TODO: add additional test code here
	}

	/**
	 * Run the void registerService(TransferService) method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:16
	 */
	@Test
	public void testRegisterService_2() throws Exception {
		TransportServer fixture = new TransportServer(1);
		TransferService service = new DemoTransferService();

		fixture.registerService(service);

		// TODO: add additional test code here
	}

	/**
	 * Run the void registerService(TransferService) method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:16
	 */
	@Test
	public void testRegisterService_3() throws Exception {
		TransportServer fixture = new TransportServer(1);
		TransferService service = new DemoTransferService();

		fixture.registerService(service);

		// TODO: add additional test code here
	}

	/**
	 * Run the void start() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:16
	 */
	@Test(expected = java.net.SocketException.class)
	public void testStart_1() throws Exception {
		TransportServer fixture = new TransportServer(1);

		fixture.start();

		// TODO: add additional test code here
	}

	/**
	 * Run the void start() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:16
	 */
	@Test(expected = java.net.SocketException.class)
	public void testStart_2() throws Exception {
		TransportServer fixture = new TransportServer(1);

		fixture.start();

		// TODO: add additional test code here
	}

	/**
	 * Run the void start() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:16
	 */
	@Test(expected = java.net.SocketException.class)
	public void testStart_3() throws Exception {
		TransportServer fixture = new TransportServer(1);

		fixture.start();

		// TODO: add additional test code here
	}

	/**
	 * Run the void start() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:16
	 */
	@Test(expected = java.net.SocketException.class)
	public void testStart_4() throws Exception {
		TransportServer fixture = new TransportServer(1);

		fixture.start();

		// TODO: add additional test code here
	}

	/**
	 * Run the void start() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:16
	 */
	@Test(expected = java.net.SocketException.class)
	public void testStart_5() throws Exception {
		TransportServer fixture = new TransportServer(1);

		fixture.start();

		// TODO: add additional test code here
	}

	/**
	 * Run the void stop() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:16
	 */
	@Test
	public void testStop_1() throws Exception {
		TransportServer fixture = new TransportServer(1);

		fixture.stop();

		// TODO: add additional test code here
	}

	/**
	 * Run the String toString() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:16
	 */
	@Test
	public void testToString_1() throws Exception {
		TransportServer fixture = new TransportServer(1);

		String result = fixture.toString();

		// TODO: add additional test code here
		assertEquals("{version: 1, port: 1}", result);
	}

	/**
	 * Run the TransportServer() constructor test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:16
	 */
	@Test
	public void testTransportServer_1() throws Exception {

		TransportServer result = new TransportServer();

		// TODO: add additional test code here
		assertNotNull(result);
		assertEquals("{version: 1, port: 6660}", result.toString());
		assertEquals(1, result.getVersion());
		assertEquals(6660, result.getPortNumber());
	}

	/**
	 * Run the TransportServer(int) constructor test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:16
	 */
	@Test
	public void testTransportServer_2() throws Exception {
		int portNumber = 1;

		TransportServer result = new TransportServer(portNumber);

		// TODO: add additional test code here
		assertNotNull(result);
		assertEquals("{version: 1, port: 1}", result.toString());
		assertEquals(1, result.getVersion());
		assertEquals(1, result.getPortNumber());
	}
}